package com.mmall.concurrency.example.immutable;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.mmall.concurrency.annoations.ThreadSafe;

import java.util.List;

@ThreadSafe
public class ImmutableExample3 {

    //此处使用list也可验证不可变，但list.add（）add方法并不显示过期
    /*private final static List<Integer> list = ImmutableList.of(1,2,3);*/

    private final static ImmutableList list = ImmutableList.of(1,2,3);

    private final static ImmutableSet set = ImmutableSet.copyOf(list);

    private final static ImmutableMap<Integer,Integer> map = ImmutableMap.of(1,2,3,4);

    private final static ImmutableMap<Integer,Integer> map2 = ImmutableMap.<Integer,Integer>builder()
            .put(1,2).put(3,4).put(5,6).build();
    public static void main(String[] args) {
        map2.put(1,4);

    }
}
